package com.xyz.app.controller;

import com.free.common.vo.ResultModel;
import com.free.ext.logger.FreeLogger;
import com.free.ext.mybatis.model.entity.PageResponseModel;
import com.sun.org.apache.regexp.internal.RE;
import com.xyz.domain.model.LotteryPeriodSearchModel;
import com.xyz.domain.model.LotteryPeriodSearchResModel;
import com.xyz.domain.table.SLottery;
import com.xyz.service.LotteryInfoService;
import com.xyz.service.YldtService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 娱乐中心
 */
@Controller
@RequestMapping("/ylzx")
public class AmusementController {

    private static final Integer PAGESIZE = 20;

    @Autowired
    private LotteryInfoService lotteryInfoService;

    @Autowired
    private YldtService yldtService;

    /**
     * 详细信息
     * @param key
     * @return
     */
    @RequestMapping("/detailInfo.json")
    @ResponseBody
    public ResultModel getLotteryInfo(String key){
        SLottery lotteryInfo = lotteryInfoService.getLotteryInfo(key);
        return ResultModel.success(lotteryInfo);
    }

    /**
     * 分页信息
     * @param condition
     * @param pageNo
     * @return
     */
    @RequestMapping("/pageInfo.json")
    @ResponseBody
    public PageResponseModel<LotteryPeriodSearchResModel> getTodayLotteryInfo(LotteryPeriodSearchModel condition, int pageNo ){
        return yldtService.getTodayLotteryInfo(condition, pageNo, PAGESIZE);
    }

    /**
     * 刷新概率
     * @param key
     * @return
     */
    @RequestMapping("/refreshRate.json")
    @ResponseBody
    public ResultModel refreshRate(String key){
        return ResultModel.success();
    }

    /**
     * 自动信息
     * @param key
     * @param params
     * @return
     */
    @RequestMapping("/automaticInfo.json")
    @ResponseBody
    public ResultModel automaticInfo(String key, Map<String,String> params){
        return ResultModel.success();
    }

    /**
     * 参与信息
     * @param key
     * @return
     */
    @RequestMapping("/joinInfo.json")
    @ResponseBody
    public ResultModel joinInfo(String key){
        return ResultModel.success();
    }


    /**
     * 趋势信息
     * @param key
     * @return
     */
    @RequestMapping("/trendcy.json")
    @ResponseBody
    public ResultModel trendcy(String key){
        return ResultModel.success();
    }

    /**
     * 模式编辑
     * @param
     * @return
     */
    @RequestMapping("/mode.json")
    @ResponseBody
    public ResultModel modeInfo(){
        return ResultModel.success();
    }

    /**
     * 模式列表
     * @return
     */
    @RequestMapping("/modeList.json")
    @ResponseBody
    public ResultModel modeList(){
        return ResultModel.success();
    }


    /*

每个游戏主题下都有n个选项（A B C D E ……N ），每个选项被投注的总分为（Fa Fb Fc Fd ……Fn），假设每一项的赔率是Pn。拿选项A的赔率举例就是:

[(Fb + Fc + Fd +……+Fn)*85% / Fa] + 1 = Pa (Pa是选项A的赔率)

之所以会乘上85%，是因为我们从你所赢的分数里扣除了15%的税务。
     */
    public ResultModel getBetRate(){
        return ResultModel.failure();
    }

}
